package com.tansun.easycare.rule.referencedata.entity;

import org.hibernate.validator.constraints.Length;

import com.tansun.easycare.rule.common.entity.RuleBaseEntity;
import com.tansun.ruledata.data.entity.DeployReferenceData;

/**
 * 规则引用数据Entity
 *
 * @author lixs
 * @version 2017-03-23
 */
public class RuleReferenceData extends RuleBaseEntity<RuleReferenceData> {

    private static final long serialVersionUID = 1L;
    private String manageId;        // 规则管理ID
    private String modelType;        // 模型类型
    private String projectCode;        // 项目编号
    private String version;        // 版本
    private String className;        // 数据集名称
    private String classNamecn;
    private String code;
    private String namecn;        // 变量中文名称
    private String nameen;        // 变量英文名称
    private String dataType;        // 数据类型
    private String refManageId;        // 引用规则ID
    private String refVersion;        // 引用版本
    private String contentType;        // 操作类型;in 输入，out :输出

    private String defaultValue;

    private String isCollections;
    private String collection;
    private String domain;

    private String pattern;

    private String domainStr;

    private String isDerives;

    private Integer seq;

    private String refName;

    private String enterPointer;//关联调用编码
    
    private String isFuncParam;//是否为函数变量,1=是
    
    private String paramId;//变量id
    
    public RuleReferenceData() {
        super();
    }

    public RuleReferenceData(String id) {
        super(id);
    }

	public DeployReferenceData changeClass() {
		DeployReferenceData newinfo = new DeployReferenceData();
		newinfo.setClassName(className);
		newinfo.setClassNamecn(classNamecn);
		newinfo.setCode(code);
		newinfo.setContentType(contentType);
		newinfo.setDataType(dataType);
		newinfo.setDefaultValue(defaultValue);
		newinfo.setDomain(domain);
		newinfo.setDomainStr(domainStr);
		newinfo.setEnterPointer(enterPointer);
		newinfo.setId(id);
		newinfo.setIsCollections(isCollections);
		newinfo.setIsDerives(isDerives);
		newinfo.setManageId(manageId);
		newinfo.setModelType(modelType);
		newinfo.setNamecn(namecn);
		newinfo.setNameen(nameen);
		newinfo.setPattern(pattern);
		newinfo.setProjectCode(projectCode);
		newinfo.setRefManageId(refManageId);
		newinfo.setRefName(refName);
		newinfo.setRefVersion(refVersion);
		newinfo.setSeq(seq);
		newinfo.setVersion(version);
		return newinfo;
	}
	
    @Length(min = 0, max = 64, message = "规则管理ID长度必须介于 0 和 64 之间")
    public String getManageId() {
        return manageId;
    }

    public void setManageId(String manageId) {
        this.manageId = manageId;
    }

    @Length(min = 0, max = 10, message = "模型类型长度必须介于 0 和 10 之间")
    public String getModelType() {
        return modelType;
    }

    public void setModelType(String modelType) {
        this.modelType = modelType;
    }

    @Length(min = 0, max = 64, message = "项目编号长度必须介于 0 和 64 之间")
    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }


    @Length(min = 0, max = 10, message = "版本长度必须介于 0 和 10 之间")
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Length(min = 0, max = 64, message = "数据集名称长度必须介于 0 和 64 之间")
    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    @Length(min = 0, max = 64, message = "变量中文名称长度必须介于 0 和 64 之间")
    public String getNamecn() {
        return namecn;
    }

    public void setNamecn(String namecn) {
        this.namecn = namecn;
    }

    @Length(min = 0, max = 64, message = "变量英文名称长度必须介于 0 和 64 之间")
    public String getNameen() {
        return nameen;
    }

    public void setNameen(String nameen) {
        this.nameen = nameen;
    }

    @Length(min = 0, max = 64, message = "数据类型长度必须介于 0 和 64 之间")
    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    @Length(min = 0, max = 64, message = "引用规则ID长度必须介于 0 和 64 之间")
    public String getRefManageId() {
        return refManageId;
    }

    public void setRefManageId(String refManageId) {
        this.refManageId = refManageId;
    }

    @Length(min = 0, max = 10, message = "引用版本长度必须介于 0 和 10 之间")
    public String getRefVersion() {
        return refVersion;
    }

    public void setRefVersion(String refVersion) {
        this.refVersion = refVersion;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getClassNamecn() {
        return classNamecn;
    }

    public void setClassNamecn(String classNamecn) {
        this.classNamecn = classNamecn;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getIsCollections() {
        return isCollections;
    }

    public void setIsCollections(String isCollections) {
        this.isCollections = isCollections;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    public String getDomainStr() {
        return domainStr;
    }

    public void setDomainStr(String domainStr) {
        this.domainStr = domainStr;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public String getIsDerives() {
        return isDerives;
    }

    public void setIsDerives(String isDerives) {
        this.isDerives = isDerives;
    }

    public String getRefName() {
        return refName;
    }

    public void setRefName(String refName) {
        this.refName = refName;
    }

	public String getEnterPointer() {
		return enterPointer;
	}

	public void setEnterPointer(String enterPointer) {
		this.enterPointer = enterPointer;
	}
	
//	public String getSql() {
//		return "INSERT INTO rule_reference_data(id,manage_id,model_type,project_code,code,version,class_name,namecn,nameen,data_type,ref_manage_id,ref_version,content_type,seq,enter_pointer,data_version) "
//				+ "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
//	}
//	public Object[] getArgs(String timeStamp) {
//		return new Object[] {this.id,this.manageId,this.modelType,this.projectCode,this.code,this.version,this.className,this.namecn,this.nameen,this.dataType,this.refManageId,this.refVersion,this.contentType,this.seq,this.enterPointer,timeStamp};
//	}
	
	public String getCollection() {
		return collection;
	}

	public void setCollection(String collection) {
		this.collection = collection;
	}

	public String getSql() {
		return "INSERT INTO rule_reference_data(id,manage_id,model_type,project_code,code,version,class_name,namecn,nameen,data_type,ref_manage_id,ref_version,content_type,create_date,seq,enter_pointer,data_version) "
				+ " values ";
	}
	public String getArgs(String timeStamp) {
		return "('"+this.id+"','"
				+isEmpty(this.manageId)+"','"
				+isEmpty(this.modelType)+"','"
				+isEmpty(this.projectCode)+"','"
				+isEmpty(this.code)+"','"
				+isEmpty(this.version)+"','"
				+isEmpty(this.className)+"','"
				+isEmpty(this.namecn)+"','"
				+isEmpty(this.nameen)+"','"
				+isEmpty(this.dataType)+"','"
				+isEmpty(this.refManageId)+"','"
				+isEmpty(this.refVersion)+"','"
				+isEmpty(this.contentType)+"',@currDate,'"
				+this.seq+"','"
				+isEmpty(this.enterPointer)+"','"
				+timeStamp+"')";
//		return new Object[] {this.id,this.manageId,this.modelType,this.projectCode,this.code,this.version,this.className,this.namecn,this.nameen,this.dataType,this.refManageId,this.refVersion,this.contentType,this.seq,this.enterPointer,timeStamp};
	}
	public String getArgs(String timeStamp,String currDate) {
		return "('"+this.id+"','"
				+isEmpty(this.manageId)+"','"
				+isEmpty(this.modelType)+"','"
				+isEmpty(this.projectCode)+"','"
				+isEmpty(this.code)+"','"
				+isEmpty(this.version)+"','"
				+isEmpty(this.className)+"','"
				+isEmpty(this.namecn)+"','"
				+isEmpty(this.nameen)+"','"
				+isEmpty(this.dataType)+"','"
				+isEmpty(this.refManageId)+"','"
				+isEmpty(this.refVersion)+"','"
				+isEmpty(this.contentType)+"','"+currDate+"','"
				+this.seq+"','"
				+isEmpty(this.enterPointer)+"','"
				+timeStamp+"')";
//		return new Object[] {this.id,this.manageId,this.modelType,this.projectCode,this.code,this.version,this.className,this.namecn,this.nameen,this.dataType,this.refManageId,this.refVersion,this.contentType,this.seq,this.enterPointer,timeStamp};
	}
	public String getIsFuncParam() {
		return isFuncParam;
	}

	public void setIsFuncParam(String isFuncParam) {
		this.isFuncParam = isFuncParam;
	}

	public String getParamId() {
		return paramId;
	}

	public void setParamId(String paramId) {
		this.paramId = paramId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((className == null) ? 0 : className.hashCode());
		result = prime * result + ((classNamecn == null) ? 0 : classNamecn.hashCode());
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + ((contentType == null) ? 0 : contentType.hashCode());
		result = prime * result + ((dataType == null) ? 0 : dataType.hashCode());
		result = prime * result + ((domain == null) ? 0 : domain.hashCode());
		result = prime * result + ((isCollections == null) ? 0 : isCollections.hashCode());
		result = prime * result + ((isDerives == null) ? 0 : isDerives.hashCode());
		result = prime * result + ((isFuncParam == null) ? 0 : isFuncParam.hashCode());
		result = prime * result + ((manageId == null) ? 0 : manageId.hashCode());
		result = prime * result + ((modelType == null) ? 0 : modelType.hashCode());
		result = prime * result + ((namecn == null) ? 0 : namecn.hashCode());
		result = prime * result + ((nameen == null) ? 0 : nameen.hashCode());
		result = prime * result + ((paramId == null) ? 0 : paramId.hashCode());
		result = prime * result + ((projectCode == null) ? 0 : projectCode.hashCode());
		result = prime * result + ((refManageId == null) ? 0 : refManageId.hashCode());
		result = prime * result + ((refName == null) ? 0 : refName.hashCode());
		result = prime * result + ((refVersion == null) ? 0 : refVersion.hashCode());
		result = prime * result + ((version == null) ? 0 : version.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		RuleReferenceData other = (RuleReferenceData) obj;
		if (className == null) {
			if (other.className != null)
				return false;
		} else if (!className.equals(other.className))
			return false;
		if (classNamecn == null) {
			if (other.classNamecn != null)
				return false;
		} else if (!classNamecn.equals(other.classNamecn))
			return false;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (contentType == null) {
			if (other.contentType != null)
				return false;
		} else if (!contentType.equals(other.contentType))
			return false;
		if (dataType == null) {
			if (other.dataType != null)
				return false;
		} else if (!dataType.equals(other.dataType))
			return false;
		if (domain == null) {
			if (other.domain != null)
				return false;
		} else if (!domain.equals(other.domain))
			return false;
		if (isCollections == null) {
			if (other.isCollections != null)
				return false;
		} else if (!isCollections.equals(other.isCollections))
			return false;
		if (isDerives == null) {
			if (other.isDerives != null)
				return false;
		} else if (!isDerives.equals(other.isDerives))
			return false;
		if (isFuncParam == null) {
			if (other.isFuncParam != null)
				return false;
		} else if (!isFuncParam.equals(other.isFuncParam))
			return false;
		if (manageId == null) {
			if (other.manageId != null)
				return false;
		} else if (!manageId.equals(other.manageId))
			return false;
		if (modelType == null) {
			if (other.modelType != null)
				return false;
		} else if (!modelType.equals(other.modelType))
			return false;
		if (namecn == null) {
			if (other.namecn != null)
				return false;
		} else if (!namecn.equals(other.namecn))
			return false;
		if (nameen == null) {
			if (other.nameen != null)
				return false;
		} else if (!nameen.equals(other.nameen))
			return false;
		if (paramId == null) {
			if (other.paramId != null)
				return false;
		} else if (!paramId.equals(other.paramId))
			return false;
		if (projectCode == null) {
			if (other.projectCode != null)
				return false;
		} else if (!projectCode.equals(other.projectCode))
			return false;
		if (refManageId == null) {
			if (other.refManageId != null)
				return false;
		} else if (!refManageId.equals(other.refManageId))
			return false;
		if (refName == null) {
			if (other.refName != null)
				return false;
		} else if (!refName.equals(other.refName))
			return false;
		if (refVersion == null) {
			if (other.refVersion != null)
				return false;
		} else if (!refVersion.equals(other.refVersion))
			return false;
		if (version == null) {
			if (other.version != null)
				return false;
		} else if (!version.equals(other.version))
			return false;
		return true;
	}
	
	
}